package com.asia5b.a5mall.member.adapter

import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.asia5b.a5mall.member.R
import com.asia5b.a5mall.middleware.model.member.RegionModel
import com.asia5b.a5mall.middleware.model.bean.TabRegionBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * Created by zhangyuncai on 2020/5/7.
 */
class RegionContentAdapter(tabDatas: ArrayList<TabRegionBean>, var callback: (selectRegionModel: RegionModel) -> Unit) :
        BaseQuickAdapter<TabRegionBean, BaseViewHolder>(R.layout.item_region_content_adapter, tabDatas) {
    override fun convert(helper: BaseViewHolder, item: TabRegionBean) {
        if (!item.contentRegionModelList.isNullOrEmpty()) {
            val recyclerView = helper.itemView as RecyclerView
            val adapter2 = RegionContentChildAdapter(item, callback)
            recyclerView.run {
                layoutManager = LinearLayoutManager(context)
                adapter = adapter2
            }
        }
    }
}